import {ref, computed} from 'vue'
import {defineStore} from 'pinia'

export const useUserStore = defineStore('user', () => {
    let user = ref({})
    let token = ref('')
    const count = ref(0)
    const doubleCount = computed(() => count.value * 2)

    function setUser(userLoginRequest) {
        user.value = userLoginRequest
    }
    function setToken(tokenStr) {
        token.value = tokenStr
    }

    const clearUser = () => {
        user.value = null;
    }
    const clearToken = () => {
        token.value = '';
    }
    return {user,token, doubleCount,setToken, setUser,clearUser,clearToken}
}, {
    // 持久化
    persist: true
},)
